package com.yunshan.mp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.mp.domain.MpServeBanner;
import com.yunshan.mp.service.IMpServeBannerService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 服务设置bannerController
 * 
 * @author yunshan
 * @date 2025-02-12
 */
@Api(tags = "服务设置banner")
@RestController
@RequestMapping("/mp/serveBanner")
public class MpServeBannerController extends BaseController
{
    @Autowired
    private IMpServeBannerService mpServeBannerService;

    /**
     * 查询服务设置banner列表
     */
    @ApiOperation("查询服务设置banner列表")
    @PreAuthorize("@ss.hasPermi('mp:serve:list')")
    @GetMapping("/list")
    public TableDataInfo list(MpServeBanner mpServeBanner)
    {
        List<MpServeBanner> list = mpServeBannerService.selectMpServeBannerList(mpServeBanner);
        return getDataTable(list);
    }

    /**
     * 导出服务设置banner列表
     */
    @ApiOperation("导出服务设置banner列表")
    @Log(title = "服务设置banner", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MpServeBanner mpServeBanner)
    {
        List<MpServeBanner> list = mpServeBannerService.selectMpServeBannerList(mpServeBanner);
        ExcelUtil<MpServeBanner> util = new ExcelUtil<MpServeBanner>(MpServeBanner.class);
        util.exportExcel(response, list, "服务设置banner数据");
    }

    /**
     * 获取服务设置banner详细信息
     */
    @ApiOperation("获取服务设置banner详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mpServeBannerService.selectMpServeBannerById(id));
    }

    /**
     * 新增服务设置banner
     */
    @ApiOperation("新增服务设置banner")
    @PreAuthorize("@ss.hasPermi('mp:serve:add')")
    @Log(title = "服务设置banner", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MpServeBanner mpServeBanner)
    {
        return toAjax(mpServeBannerService.insertMpServeBanner(mpServeBanner));
    }

    /**
     * 修改服务设置banner
     */
    @ApiOperation("修改服务设置banner")
    @Log(title = "服务设置banner", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MpServeBanner mpServeBanner)
    {
        return toAjax(mpServeBannerService.updateMpServeBanner(mpServeBanner));
    }

    /**
     * 删除服务设置banner
     */
    @ApiOperation("删除服务设置banner")
    @Log(title = "服务设置banner", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mpServeBannerService.deleteMpServeBannerByIds(ids));
    }
}
